package cn.udesk.web.controller;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.udesk.common.toolkit.Constant;
import cn.udesk.web.service.TransService;
import cn.udesk.web.utils.JsonUtils;

@RestController
@RequestMapping("/main/")
public class MainController {

  @Autowired
  private TransService transService;

  @RequestMapping("getAllTransCount.shtml")
  public String getAllTransCount(HttpServletRequest request) {
    return JsonUtils.objectToJson(transService.getTransCount(null));
  }

  @RequestMapping("getTransRuningCount.shtml")
  public String getTransRuningCount(HttpServletRequest request) {
    return JsonUtils.objectToJson(transService.getTransCount(Constant.TRANS_RUNNING));
  }

  @RequestMapping("getTransStopedCount.shtml")
  public String getTransStopedCount(HttpServletRequest request) {
    return JsonUtils.objectToJson(transService.getTransCount(Constant.TRANS_STOPED));
  }
}
